package thread;

/**
 * 测试λ
 *
 * @author dingwen
 * @date 2021/09/05
 */
public class TestLambda {

    /**
     * like2
     * 静态内部类实现
     *
     * @author dingwen
     * @date 2021/09/05
     */
    static class Like2 implements ILike{
        @Override
        public void lambda() {
            System.out.println("i like lambda");
        }
    }

    public static void main(String[] args) {
        Like2 like2 = new Like2();
        Like like = new Like();
        like.lambda();
        like2.lambda();

        /**
         * 局部内部类
         *
         * @author dingwen
         * @date 2021/09/05
         */
        class Like3 implements ILike{
            @Override
            public void lambda() {
                System.out.println("i like lambda");
            }
        }

        Like3 like3  = new Like3();
        like3.lambda();

        // 匿名内部类
        ILike like4 = new ILike() {
            @Override
            public void lambda() {
                System.out.println("i like lambda");
            }
        };
        like4.lambda();


    }
}


interface ILike {
    /**
     * λ
     */
    void lambda();
}


/**
 * 外部类
 *
 * @author dingwen
 * @date 2021/09/05
 */
class Like implements ILike{
    @Override
    public void lambda() {
        System.out.println("i like lambda");
    }
}